import { API } from '@/services/model/baseModel';
import { CouponCategoryModel, MyCouponModel } from '@/services/model/couponModel';
import config from '@/utils/config';
import { request } from '@/utils/http';

/**
 * 优惠券
 * @param categoryId 分类id
 * @returns
 */
const getCouponList = (categoryId: number) => {
  return request.get<API<CouponCategoryModel>>(
    config.url.coupon_category + '?categoryId=' + categoryId,
  );
};

/**
 * 我的优惠券
 * @returns
 */
const getMyCoupon = () => {
  return request.get<API<MyCouponModel>>(config.url.coupon_my, {});
};

/**
 * 领取优惠券
 * @param couponId 优惠券id
 * @returns
 */
const receiveCoupon = (couponId: number) => {
  return request.get<API<String>>(config.url.coupon_receive + '?couponId=' + couponId);
};

export { getCouponList, getMyCoupon, receiveCoupon };
